package com.cn.client.controller;

import com.cn.api.ProductCoreService;
import com.cn.client.vo.productVO.*;
import com.cn.common.result.Result;
import com.cn.dto.ProductDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;

/**
 * @Description: FrontProductController
 * @Author: ZhangMao
 * @Date: 2022-02-18
 */
@Slf4j
@Api(tags = "C端产品查询")
@RestController
@RequestMapping("/front/product")
public class ProductController {
    @Resource
    private ProductCoreService productCoreService;


    @ApiOperation(value = "产品列表")
    @GetMapping("/findAll")
    public Result<List<FrontProductListReturnVO>> findAll(FrontProductListVO frontProductListVO) {
        ProductDTO productDTO = new ProductDTO();

        /**
        * vo转dto
        * 查询条件
        */
        productDTO.setSortField(frontProductListVO.getSortField());//排序字段
        productDTO.setSortord(frontProductListVO.getSortord());//排序方式
        productDTO.setScenicType(frontProductListVO.getScenicType());//景区类型
        productDTO.setScenicGrade(frontProductListVO.getScenicGrade());//景区等级


        log.info("\n应用层：产品***************************");
        productCoreService.findAll(productDTO);


        return Result.success(null);
    }

    @ApiOperation(value = "查询单个产品详情")
    @GetMapping(value = "/productDetails")
    public Result<FrontProductReturnVO> productDetails(FrontProductVO frontProductVO) {
        ProductDTO productDTO = new ProductDTO();
        FrontProductReturnVO frontProductVO1 = new FrontProductReturnVO();

        productDTO = productCoreService.findById(frontProductVO.getProductId());
        frontProductVO1.setName(productDTO.getName());
        frontProductVO1.setCity(productDTO.getLogo());

//        System.out.println(productDTO);


        return Result.success(frontProductVO1);
    }

    @ApiOperation(value = "门票选购")
    @GetMapping(value = "/selectTickets")
    public Result<FrontSelectTicketsReturnVO> selectTickets(FrontProductVO frontProductVO) {
        FrontSelectTicketsReturnVO fstr = new FrontSelectTicketsReturnVO();
        return null;
    }
}

